<?php
//User interface that allows a user to complete a newly created inspection or finish an inspection in progress.
	include 'common.php';
	include 'templateHandler.php';
	
	print_header();
	session_start();
	$user = $_SESSION['user'];
	//$prevPage = $_SESSION['prev'];
	if(isset($_REQUEST["file"])){
		$file=$_REQUEST["file"];
		$split=explode("_",$file);
		$facility= $split[0] . '_';
		$time= $split[1] . '_';
		$date= $split[2] . '_';
		$protocol= trim($split[3]);
	}
	else{
		$facility=$_REQUEST["facility"];
		$time=$_REQUEST["time"];
		$date=$_REQUEST["date"];
		$protocol=$_REQUEST["protocol"];
	}
?>		
	<div class="header">
			UserName: <?= $user ?>
			</br>
			FileName: "<?= $facility, $time, $date, $protocol?>"
			<form action="index.php">
				<button type="submit" class="buttons">Log Out</button>
			</form>
			<form action="controlpanel.php">
				<button type="submit" class="buttons">Back</button>
			</form>
			<button class="buttons">Save</button>
		</div>	
		
		<div class="forms">
			<!-- add function here that parses template file -->
			
			<?php 
				$arrayOfStrings = readTemplate("protocol1.txt"); 
				$arrayOfGroups = parseTemplateLines($arrayOfStrings);
				loadTemplate($arrayOfGroups);
			?>
		</div>
<?php
	print_footer();
?>